﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TestGraph.Interfaces;

namespace TestGraph
{
    class Program
    {
        static void Main(string[] args)
        {
            IBasicGraph graph = new BasicGraph();

            Vertex root = new Vertex("http://public.ucn.dk/fen/testsite/");
            TestCase(graph, root);

            Console.WriteLine("Depth First Search - Iterative");
            foreach (Vertex v in graph.DfsIterative(root))
            {
                Console.WriteLine(v.Name);
            }

            Console.WriteLine("\nDepth First Search - Recursive");
            foreach (Vertex v in graph.DfsRecursive(root))
            {
                Console.WriteLine(v.Name);
            }

            Console.WriteLine("\nBreadth First Search - Iterative");
            foreach (Vertex v in graph.BfsIterative(root))
            {
                Console.WriteLine(v.Name);
            }

            Console.ReadLine();
        }

        private static void TestCase(IBasicGraph graph, Vertex root)
        {
            Vertex sub01 = new Vertex("http://public.ucn.dk/fen/testsite/leaf01.htm");
            Vertex sub02 = new Vertex("http://public.ucn.dk/fen/testsite/internaldoc02.htm");
            Vertex sub03 = new Vertex("http://public.ucn.dk/fen/testsite/index.htm");
            graph.AddVertex(root);
            graph.AddVertex(sub01);
            graph.AddVertex(sub02); //subroot
            graph.AddVertex(sub03);
            graph.AddEdge(root, sub01);
            graph.AddEdge(root, sub02);
            graph.AddEdge(root, sub03);

            Vertex sub11 = new Vertex("http://public.ucn.dk/fen/testsite/internaldoc02/leaf01.htm");
            Vertex sub111 = new Vertex("http://public.ucn.dk/fen/testsite/internaldoc02/--deep.htm");
            Vertex sub12 = new Vertex("http://public.ucn.dk/fen/testsite/internaldoc02/leaf02.htm");
            Vertex sub13 = new Vertex("http://public.ucn.dk/fen/testsite/internaldoc02/internaldoc01.htm");
            graph.AddVertex(sub11);
            graph.AddVertex(sub111); // deep test
            graph.AddVertex(sub12);
            graph.AddVertex(sub13); // subroot
            graph.AddEdge(sub02, sub11);
            graph.AddEdge(sub02, sub111);
            graph.AddEdge(sub02, sub12);
            graph.AddEdge(sub02, sub13);

            Vertex sub21 = new Vertex("http://public.ucn.dk/fen/testsite/internaldoc01/leaf03.htm");
            Vertex sub22 = new Vertex("http://public.ucn.dk/fen/testsite/internaldoc01/index.htm");
            graph.AddVertex(sub21);
            graph.AddVertex(sub22);
            graph.AddEdge(sub13, sub21);
            graph.AddEdge(sub13, sub22);

            Vertex sub31 = new Vertex("http://public.ucn.dk/fen/testsite/internaldoc02/--deep/-deeper.htm");
            Vertex sub32 = new Vertex("http://public.ucn.dk/fen/testsite/internaldoc02/--deep/leaf04.htm");
            graph.AddVertex(sub31);
            graph.AddVertex(sub32);
            graph.AddEdge(sub111, sub31);
            graph.AddEdge(sub111, sub32);

            Vertex sub41 = new Vertex("http://public.ucn.dk/fen/testsite/internaldoc02/--deep/-deeper/leaf05.htm");
            Vertex sub42 = new Vertex("http://public.ucn.dk/fen/testsite/internaldoc02/--deep/-deeper/leaf06.htm");
            graph.AddVertex(sub41);
            graph.AddVertex(sub42);
            graph.AddEdge(sub31, sub41);
            graph.AddEdge(sub31, sub42);
        }
    }
}
